#!/bin/bash
# wxWidgets 子模块镜像配置工具 - Shell 脚本版本

echo "========================================"
echo "   wxWidgets 子模块镜像配置工具"
echo "========================================"
echo

echo "正在配置 Git 镜像规则..."
echo

# 配置各个子模块的镜像
echo "配置 expat 镜像..."
git config --local url.https://gitee.com/mirrors/expat.insteadOf https://github.com/libexpat/libexpat
if [ $? -eq 0 ]; then
    echo "✅ expat 镜像配置成功"
else
    echo "❌ expat 镜像配置失败"
fi

echo "配置 zlib 镜像..."
git config --local url.https://gitee.com/mirrors/zlib.insteadOf https://github.com/madler/zlib
if [ $? -eq 0 ]; then
    echo "✅ zlib 镜像配置成功"
else
    echo "❌ zlib 镜像配置失败"
fi

echo "配置 libpng 镜像..."
git config --local url.https://gitee.com/mirrors/libpng.insteadOf https://github.com/glennrp/libpng
if [ $? -eq 0 ]; then
    echo "✅ libpng 镜像配置成功"
else
    echo "❌ libpng 镜像配置失败"
fi

echo "配置 libtiff 镜像..."
git config --local url.https://gitee.com/mirrors/libtiff.insteadOf https://gitlab.com/libtiff/libtiff
if [ $? -eq 0 ]; then
    echo "✅ libtiff 镜像配置成功"
else
    echo "❌ libtiff 镜像配置失败"
fi

echo "配置 libjpeg-turbo 镜像..."
git config --local url.https://gitee.com/mirrors/libjpeg-turbo.insteadOf https://github.com/libjpeg-turbo/libjpeg-turbo
if [ $? -eq 0 ]; then
    echo "✅ libjpeg-turbo 镜像配置成功"
else
    echo "❌ libjpeg-turbo 镜像配置失败"
fi

echo
echo "========================================"
echo "✅ 镜像配置完成！"
echo
echo "现在可以运行以下命令初始化子模块："
echo "  git submodule update --init --recursive"
echo
echo "要验证配置，可以运行："
echo "  git config --local --list | grep insteadOf"
echo "========================================"
